package com.wuxianedu.urldemo;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import java.io.IOException;
import java.net.MalformedURLException;

public class MainActivity extends AppCompatActivity {

    Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Bitmap bitmap = (Bitmap) msg.obj;
            iv.setImageBitmap(bitmap);
        }
    };
    private ImageView iv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv = (ImageView) findViewById(R.id.iv);


        new Thread(){
            @Override
            public void run() {

                try {
                    Utils.myMethod();

                   /* Bitmap bitmap = Utils.myMethod();
                    Message msg = new Message();
                    msg.obj = bitmap;
                    handler.sendMessage(msg);*/
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }
}
